﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Info_AddStudentIn : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] == null)
        {
            Response.Write("<script>alert('请先登录!');window.location.href='../Login.aspx'</script>");
        }
        else
        {
            if (!IsPostBack)
            {
                ArrayList al1 = new Sqlselete().SelectClassId();
                for (int j = 0; j < al1.Count; j++)
                {
                    DropDownList1.Items.Add(al1[j].ToString());
                }
            }
        }
    }
  
    protected void Submit1_ServerClick(object sender, EventArgs e)
    {
        try
        {
            string Names = this.Name.Text.Trim();
            int Ages = Convert.ToInt32(this.age.Text);
            string Sexs = this.Sex.SelectedItem.Text;
            string Addresss = this.address.Text;
            string Phones = this.phone.Text;
            string ClassIds = DropDownList1.SelectedItem.Text.ToString();
            string addtime=DateTime.Now.ToShortDateString();
            SqlInsert sl = new SqlInsert();
            if (sl.InsertStudentInfo(Names, Ages, Sexs, Addresss, Phones, ClassIds,addtime)> 0)
            {

                string UserName = Session["UserName"].ToString();
                string WorkInfo = "成功添加了" + Name + "同学";
                string ip = Request.UserHostAddress.ToString();
                sl.InsertWorkLog(UserName, WorkInfo, ip);
                Response.Write("<script>alert('添加成功！！');window.location.href='ManInfo.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('请填写完整的资料！！')</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
}
